import store from '../store'
import {delEmptyParam} from '@/util/stringUtil.js'

function _handlerAppMessagePath(url) {
	if (!url) {
		// #ifdef MP-WEIXIN
		var pages = getCurrentPages();
		var returnUrl = pages[pages.length - 1].route + '?';
		var options = pages[pages.length - 1].options;
		if (options) {
			for (let [key, value] of Object.entries(options)) {
				returnUrl += key + '=' + value + '&';
			}
		}
		// #endif
		// #ifdef H5
		var returnUrl=window.location.href;
		// #endif
	
		url =delEmptyParam(returnUrl);
		 //returnUrl.substr(0, returnUrl.length - 1);  
	}
	var path = 'pages/share/share?shareUserId=' + store.state.user.clientUserId +
		'&returnUrl=' + encodeURIComponent(url);
	// #ifdef H5
	path = store.state.common.hostDomain + path;
	// #endif
	return path;
}
export const handlerAppMessagePath = _handlerAppMessagePath;
